var http = require("http");
var fs   = require("fs");

http.createServer((req,res) => {
    //设置页面编码
    res.setHeader("Content-type","text/html;charset=UTF-8");
    if(req.url == "/haha.html"){
        fs.readFile("./public/b.html",function(err,data){
            res.end(data);
        });
    }else if(req.url == "/css.css"){
        fs.readFile("./public/css.css",function(err,data){
            res.end(data);
        });
    }else if(req.url == "/0.jpg"){
        fs.readFile("./public/0.jpg",function(err,data){
            res.end(data);
        });
    }else if(req.url == "/s.js"){
        fs.readFile("./public/s.js",function(err,data){
            res.end(data);
        });

    }else if(req.url == "/dataInfo"){
        fs.readFile("./public/json.js",function(err,data){
            res.end(data);
        });
        
    }else{
        res.end("没有这个页面");
    }
}).listen(3000);

console.log("NodeJS Server Start at 3000 port");